﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Stamp_For_Africa_Version_2.Models;
using Stamp_For_Africa_Version_2.Repositories;

namespace Stamp_For_Africa_Version_2.Controllers
{
    public class SeriesController : Controller
    {
        //
        // GET: /Series/

        public ActionResult Index()
        {
          SeriesRepository seriesRepository = new SeriesRepository();
            return View(seriesRepository.FindAllSeries());
        }

      public ActionResult Create()
      {
        return View();
      }

      [AcceptVerbs(HttpVerbs.Post)]
      public ActionResult Create(Series series)
      {
        SeriesRepository seriesRepository = new SeriesRepository();
        Series nSeries = new Series();
        nSeries.Id = Guid.NewGuid();
        nSeries.DateFrom = series.DateFrom;
        nSeries.DateFrom = series.DateTo;
        nSeries.Name = series.Name;

        
        seriesRepository.Add(nSeries);
        seriesRepository.Save();
        return RedirectToAction("Details", nSeries);
      }

      public ActionResult Details()
      {
        return View();
      }
    }
}
